#ifndef MSGINF_H
#define MSGINF_H
#include <QString>
#include <QWidget>
#include <QInputDialog>
#include <QMessageBox>

#include <libintl.h>
#define _(STRING) QString::fromLocal8Bit(gettext(STRING))
using namespace std;

template<typename ... Args>
std::string string_sprintf(const char* format, Args... args) {
    int length = std::snprintf(nullptr, 0, format, args...);
    if (length <= 0) {
        return "";
    }

    char* buf = new char[length + 1];
    std::snprintf(buf, length + 1, format, args...);

    std::string str(buf);
    delete[] buf;
    return std::move(str);
}
class MSGINF
{
public:
    static QString MsgGetItem(QWidget *parent,QString title,QString label,QStringList items,bool *ok=nullptr);
    static QString MsgGetText(QWidget *parent,QString title,QString label,bool *ok=nullptr);
    static int MsgShowOk(QWidget *parent,QString title,QString label,QMessageBox::StandardButtons bOk = QMessageBox::Ok);
    static int MsgAbout(QWidget *parent,QString title,QString label,QMessageBox::StandardButtons bOk = QMessageBox::Ok);
    static std::vector<std::string> stringSplit(const std::string& str, char delim);
    static string& replace_str(string& str, const string& to_replaced, const string& newchars);

};

#endif // MSGINF_H
